﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="EmpPublicacion.aspx.cs" Inherits="EmpPublicacion" Title="Publicación"
    ValidateRequest="false" %>
<%@ Register Src="imgUpload.ascx" TagName="img_upload" TagPrefix="iu" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body" runat="Server">

    <script src="JS/tiny_mce/jquery.tinymce.js" type="text/javascript"></script>

    <ajax:UpdatePanel ID="up_tinymce" runat="server">
        <Triggers>
            <ajax:PostBackTrigger ControlID="btn_guardar" />
        </Triggers>
        <ContentTemplate>
            <div style="text-align:center;">
                <asp:Button ID="btn_guardar" runat="server" Text="Guardar" OnClick="btn_guardar_Click" OnClientClick="javascript:create();" />
                <asp:Button ID="btn_cancelar" runat="server" Text="Cancelar" onclick="btn_cancelar_Click" />
            </div>    
            <ul id="ul_mensajes" runat="server"></ul>
            <div id="div_contenido_edit" runat="server" class="accordion">
                    <h3><a href="#">Configuración</a></h3>
	                <div>
	                    <span class="membrete">Nro Publicación</span>
	                    <asp:Label ID="lbl_nropublicacion" runat="server" Text="Nueva" CssClass="membretedato"></asp:Label>
                        <span class="membrete">Descripción</span>
                        <asp:TextBox ID="txt_descripcion" runat="server" Width="500" MaxLength="50"></asp:TextBox>
                        <span class="membrete">Logo <span class="tooltip" alt="Esta imagen será visible para los usuarios como la portada de la publicación">?</span></span>
                        <asp:Image ID="img_logo" ImageUrl="~/static/sin_imagen.png" runat="server" Width="70" Height="70" /><!-- "Vos gritás -¡No Logo! / o no gritás -¡No Logo! / O gritás -¡No Logo... no!" ;) -->
                        <span class="membrete">Fecha Caducación</span>
                        <asp:TextBox ID="txt_fcaducacion" runat="server" CssClass="calendar" MaxLength="10"></asp:TextBox>
                    </div>
    	            <h3><a href="#">Contenido</a></h3>
	                <div>
                        <textarea name="content" class="tinymce" style="width: 100%; height: 600px;" id="ta_contenido"
                        runat="server"></textarea>
                    </div>
            </div>
            
            <div id="d_upload" class="" style="display:none;" title="Pregunta">
                <iu:img_upload id="iu_ctrl" runat="server" />    
            </div>
            <script type="text/javascript" language="javascript">
        
                $().ready(bind_upload);
                aspbh_endHandler.push(bind_upload);
                
                function bind_upload(){ 
                    if($("#<%= btn_guardar.ClientID %>").is(":not(:enabled)"))
                        return;
                
                    $( "#d_upload" ).dialog({
                        title: 'Seleccione el archivo a subir',
                        modal: false,
                        width: 600,
                        autoOpen:false,
                        stack: true
                    })
                    
                    $("#d_upload","form").remove();
      
      
                    $("#<%= img_logo.ClientID %>")
                        .click(function(){
                            $( "#d_upload" )
                                .dialog('open')
                                .parents(".ui-dialog")
                                .detach()
                                .appendTo("form")
                                .show();
                        }); 
                }
                            
            </script>
        </ContentTemplate>
    </ajax:UpdatePanel>

    <script type="text/javascript">
        var objContenidoEdit = '<%= div_contenido_edit.ClientID %>';
        var obj_ta_contenido = '<%= ta_contenido.ClientID %>';
        
        dysplayHandler();
                
        $('textarea.tinymce').tinymce({
                oninit: hideHandler,
                readonly : $('textarea.tinymce').is(':not(:enabled)'),
                // Location of TinyMCE script
                script_url : 'JS/tiny_mce/tiny_mce.js',
                
                // lenguaje
                language : "es",
                
                // General options
                theme : "advanced",
                plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
                file_browser_callback : "filebrowser",
                // Theme options
                theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
                theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,|,insertdate,inserttime,preview,|,forecolor,backcolor",
                theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
                theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
                theme_advanced_toolbar_location : "top",
                theme_advanced_toolbar_align : "left",
                theme_advanced_statusbar_location : "bottom",
                theme_advanced_resizing : true,

                // Drop lists for link/image/media/template dialogs
                template_external_list_url : "lists/template_list.js",
                external_link_list_url : "lists/link_list.js",
                external_image_list_url : "lists/image_list.js",
                media_external_list_url : "lists/media_list.js",

                save_enablewhendirty : false,

                template_templates : [
                        {
                                title : "Prueba 1",
                                src : "template1.html",
                                description : "Template de prueba"
                        }
                ],

                // Replace values for the template plugin
                template_replace_values : {
                        username : "Administración",
                        staffid : "REEMPLAZADO"
                }
                
                
        });
                
        function filebrowser(){/*
            $( "#d_upload" )
                                .dialog('open')
                                .parents(".ui-dialog")
                                .detach()
                                .appendTo("form")
                                .show()
                                .css("z-index",1000000);*/
            //http://www.neele.name/filebrowser/
            //http://www.tinymce.com/wiki.php/How-to_implement_a_custom_file_browser
        }
        function create(){
            $("#" + obj_ta_contenido).html(tinymce.get(0).getContent());
            
        }

    </script>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="Server">
</asp:Content>
